<?php
/**
 *
 *
 */
namespace Yz\modules\Generic;


class Controller_Page
    extends \Yz_Controller_Templated
    implements \Yz_Controller_Interface
{

#    protected $templateName = 'news-default';

    /**
     *
     */
    protected function doGET()
    {
        debug();
        $model = $this->module->selectModel("List");

        $pageNr = $this->fetchArgument(0);
        $pagerClass = $this->module->resolveClass("Pagination_Default");
        $pager = new $pagerClass($pageNr);
        $list = $model->fetchPage($pager);


        if (0 === $list->count()) {
            $template = $this->selectTemplate('no-items');
        } else {
            $template = $this->selectTemplate();
            $template->list = $list;
        }
        $template->page = $pager;


        $this->outputTemplate($template);
        return $this;
    }

}
